/**
 * Created with JetBrains WebStorm.
 * User: 可乐加糖
 * Date: 13-7-29
 * Time: 下午10:51
 * To change this template use File | Settings | File Templates.
 */

var cluster = require("cluster");
var http = require("http");
var munCPUS = require('os').cpus().length;

if(cluster.isMaster){
    //创建工作进程
    for(var i=0;i<munCPUS;i++){
        cluster.fork();
    }

    cluster.on('death',function(worker){
        console.log("worker "+worker.pid+" died");
    });
}else{
    //工作进程创建HTTP服务器
    http.Server(function(req,res){
        res.writeHead(200);
        res.end("hello word\n");
    }).listen(8000);
}
